from django.db import models
from django.utils import timezone
from blog.models import Blog


# Create your models here.


class Comment(models.Model):
    nickname = models.CharField('名字', max_length=50)
    email = models.EmailField('邮箱')
    content = models.TextField('内容')
    created_time = models.DateTimeField('创建时间', default=timezone.now)
    post = models.ForeignKey(Blog, verbose_name='文章', on_delete=models.CASCADE)

    class Meta:
        verbose_name = '评论'
        verbose_name_plural = verbose_name
        ordering = ('-created_time',)

    def __str__(self):
        return '{}: {}'.format(self.nickname, self.content[:20])

